''' <summary>
''' Encapsulates tab information for a specified control/page.
''' </summary>
Public Class TabPage
    Public Event ParentChanged()

    Friend TabPageCtl As New TabPageControl(Me)

    Private myParent As PageCollection = Nothing
    ''' <summary>
    ''' Gets the tabpages control to which this page belongs.
    ''' </summary>
    Public ReadOnly Property Parent() As PageCollection
        Get
            Return myParent
        End Get
    End Property

    ''' <summary>
    ''' Gets or sets the text to be displayed in the tab.
    ''' </summary>
    Public Property Text() As String
        Get
            Return TabPageCtl.Text
        End Get
        Set(ByVal value As String)
            TabPageCtl.Text = value
        End Set
    End Property

    ''' <summary>
    ''' Gets or sets the text to be displayed as the tab's tool-tip (in addition to the tab's text).
    ''' </summary>
    Public Property ToolTip() As String
        Get
            Return TabPageCtl.ToolTip
        End Get
        Set(ByVal value As String)
            TabPageCtl.ToolTip = value
        End Set
    End Property

    Private myControl As Windows.Forms.Control = Nothing
    ''' <summary>
    ''' Gets or sets the control to be displayed when this tab is selected.
    ''' </summary>
    Public Property Control() As Windows.Forms.Control
        Get
            Return myControl
        End Get
        Set(ByVal value As Windows.Forms.Control)
            myControl = value
        End Set
    End Property

    ''' <summary>
    ''' Closes this tab (and raises the close event).
    ''' </summary>
    Public Sub Close()
        Me.TabPageCtl.Close()
    End Sub

    Public Sub New(ByVal text As String, ByVal control As Windows.Forms.Control, Optional ByVal toolTip As String = Nothing)
        Me.Text = text
        Me.Control = control
        Me.ToolTip = toolTip
    End Sub

    Friend Sub SetParent(ByVal parent As PageCollection)
        Me.myParent = parent
        RaiseEvent ParentChanged()
    End Sub
End Class